package com.eight.travel.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.eight.travel.dao.AdminFoodMapper;
import com.eight.travel.pojo.FoodMp;
import com.eight.travel.pojo.Foodrestaurant;
import com.eight.travel.service.AdminFoodService;
import com.eight.travel.utils.BaseResp;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AdminFoodServiceImpl extends ServiceImpl<AdminFoodMapper, FoodMp> implements AdminFoodService {
@Resource
    AdminFoodMapper adminFoodMapper;
    @Override
    public BaseResp findAllrest() {
        List<Foodrestaurant> allrest = adminFoodMapper.findAllrest();
        if (allrest.size()!=0)
            return new BaseResp().SUCCESS("cg",allrest,null);
        return new BaseResp().FAIL("sb");
    }

    @Override
    public BaseResp deleterestById(int faid) {
        int i = adminFoodMapper.deleterestById(faid);
        if (i==1)
            return new BaseResp().SUCCESS("成功",null,null);
        return new BaseResp().FAIL("失败");
    }

    @Override
    public BaseResp updaterest(Foodrestaurant foodrestaurant) {
        int update = adminFoodMapper.update(foodrestaurant);
        if (update==1)
            return new BaseResp().SUCCESS("成功",null,null);

        return new BaseResp().FAIL("失败");
    }

    @Override
    public BaseResp addrest(Foodrestaurant foodrestaurant) {
        int add = adminFoodMapper.add(foodrestaurant);
        if (add==1)
            return new BaseResp().SUCCESS("成功",null,null);
        return new BaseResp().FAIL("失败");
    }

    @Override
    public BaseResp updateststus(int faid) {
        int i = adminFoodMapper.updateststus(faid);
        if (i==1)
            return new BaseResp().SUCCESS("成功",null,null);
        return new BaseResp().FAIL("失败");

    }
}
